import count from './js/count';
// import add from './js/add';
import { add2 } from './js/math';
import './css/index.css'

import './less/index.less'
import './sass/index.sass'
import './sass/index.scss'

import './stylus/index.styl'

let a = 11;
console.log(add2(22, 2));
console.log(count(22, 2), a);
document.getElementById("btn").onclick= function(){
  // /* webpackChunkName: "addName" */ webpack魔法命名
  import(/* webpackChunkName: "addName" */ "./js/add")
  .then((res)=>{
    const {add} = res;
    console.log(add(1,2,3,3));
  })
  .catch((err)=>{
    console.log(err);
  })
}

if (module.hot) {
  // 判断是否支持热模块替换功能
  module.hot.accept("./js/count");
}
new Promise((res)=>{
  setTimeout(()=>{
    res()
  },1000)
})

if ('serviceWorker' in navigator) {
  window.addEventListener('load', () => {
    navigator.serviceWorker.register('/service-worker.js').then(registration => {
      console.log('SW registered: ', registration);
    }).catch(registrationError => {
      console.log('SW registration failed: ', registrationError);
    });
  });
}